/**
 * 
 */
package com.thon.service.project.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thon.dao.project.RegionDao;
import com.thon.dao.util.Page;
import com.thon.entity.project.Region;
import com.thon.service.project.RegionService;

/**
 * @author thon
 * @mail thon.ju@gmail.com
 * @date Nov 25, 2013 2:59:30 PM
 * @description TODO
 */
@Service
@Transactional
public class RegionServiceImpl implements RegionService {
	@Autowired
	private RegionDao regionDao;

	@Override
	public Page<Region> findRegionPage(int pageNo, int pageSize) {
		Page<Region> page = new Page<Region>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);

		return regionDao.findRegionPage(page);
	}

	@Override
	public List<Region> listRegions(int parentId) {
		return regionDao.listRegions(parentId);
	}

	@Override
	public List<Region> listRegionsByLevel(Byte level) {
		return regionDao.listRegionsByLevel(level);
	}

	@Override
	public void updateRegion(Region region) {
		regionDao.update(region);
	}

	@Override
	public void addRegion(Region region) {
		regionDao.save(region);
	}

	@Override
	public Page<Region> findRegiong(int pageNo, int pageSize, Byte level) {
		
		Page<Region> page = new Page<Region>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		return regionDao.findRegion(page, level);
	}

	@Override
	public List<Region> listRegionById(int id) {
		
		return regionDao.listRegionById(id);
	}

	@Override
	public Region getRegionById(int id) {
		
		return regionDao.getRegionById(id);
	}

}
